package controllers

import (
	"github.com/revel/revel"
	"waterblabla/app/models"
)

type DevManager struct {
	Controller
}

func (c DevManager) ImportDevs() revel.Result {
	// parse
	type Devs struct {
		Devs []string `json:"devs" valid:"Required"`
	}
	var devs Devs
	if err := models.ParseBodyAndValidate(c.body, &devs); err != nil {
		return c.RenderResult(err)
	}

	if err := models.Import(devs.Devs); err != nil {
		return c.RenderResult(err)
	}

	return c.RenderResult(nil)
}

/*
func (c Dev) UnbindDev() revel.Result {
	// parse
	var sn string
	if err := models.ParseBodyAndValidate(c.body, &struct {
		Sn *string `json:"sn" valid:"Required"`
	}{&sn}); err != nil {
		c.RenderResult(err)
	}
	// unbind
	return c.RenderResult(models.UnBindAdmin(sn))
}*/
